//此文件是用来统一发送请求的，以便于将来统一维护或是管理，比如更改接口
//1.ajax
import ajax from './ajax'


import mockAjax from './mockAjax'

//发送请求，获取三级分类列表的数据
// export function  reqCategoryListData(){
//      return  ajax.get('/product/getBaseCategoryList')
// }

//或者2.获取三级分类列表的数据
export const reqCategoryListData = () => ajax.get('/product/getBaseCategoryList')



// 3.发送请求 获取mock数据，轮播图
export const reqBannerListData = () => mockAjax.get('/banner')


//4. 发送请求 获取floor数据
export const reqFloorListData = () => mockAjax.get('/floor')


//5.发送请求，获取搜索数据，这个不是List，因为不是数组，而是一个对象
export const reqSearchGoodsInfo = (searchParams) => ajax.post('/list',searchParams)

//6.获取商品的详情数据（detail页面）
export const reqGoodDetailInfoData = (id) =>ajax.get('/item/'+ id)

//7.添加购物车
export const reqAddOrUpdateCart = (skuId,skuNum)=>ajax.post(`/cart/addToCart/${ skuId }/${ skuNum }`)

//8.发送请求获取购物车中的商品数据
export const reqShopCartListData = () =>ajax.get('/cart/cartList')


//9.更新购物车中数据的选中状态
export const reqChangeShopCartInfoState = (skuID,isChecked) =>ajax.get(`/cart/checkCart/${skuID}/${isChecked}`)

//10.删除一件购物车的商品
export const reqDelOneShopCartInfo = (skuId) => ajax.delete(`/cart/deleteCart/${skuId}`)

//11.批量删除购物车中选中的商品
export const reqDelSelectedCartInfo = (cartInfo)=>ajax.delete('/cart/batchDeleteCart',cartInfo)

//12.获取手机验证码
// export const reqCode = (phone) => ajax.get(`/user/passport/sendCode/${phone}`)
export const reqCode = (phone)=>{
     return  ajax({
            url:`/user/passport/sendCode/${phone}`,
            method:'get',
     })
}

//13.注册账号
// export const reqRegister = (user)=>ajax.post('/user/passport/register',user)
export const  reqRegister = (user) =>{
     return ajax({
          url:'/user/passport/register',
          method:'post',
          data:user
     })
}

//14.实现登录
// export const reqLogin=(user)=>ajax.post('/user/passport/login',user)
export const reqUserLogin = (user)=>{
     return ajax({
         url:'/user/passport/login',
         method:'post',
         data:user
     })
}

//15.根据token获取用户信息
export  const  reqGetUserInfo  = ()=>{
      return ajax({
          url:'/user/passport/auth/getUserInfo',
          method:'get',
      })
}


//16.登出
// export const reqLoginout = () =>ajax.get('/user/passport/logout')
export const  reqUserLogout = () =>{
       return ajax({
          url:'/user/passport/logout',
          method:'get',
       })
}

//17.获取收件人信息
export const  reqUserAddressList = ()=>{
       return ajax({
             url:'/user/userAddress/auth/findUserAddressList',
             method:'get',
       })
}

//18.获取交易页信息
export const  reqTradeInfo =()=>{
      return ajax({
            url:'/order/auth/trade',
            method:'get'
      })
}

//19.请求提交创建订单  
export  const  reqSubmitOrder = (tradeNo,tradeInfo) =>{
      return ajax({
          url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,
          method:'post',
          data:tradeInfo  //准备一个对象接收从后台传过来的很多的数据
      })
}

//20.请求获取订单支付信息（应付金额那里需要,还有微信二维码）
export const reqPayInfo = (orderId)=>{
       return ajax({
           url:`/payment/weixin/createNative/${orderId}`,
           method:'get',
       })
}

//21.查询支付订单状态（看用户扫没扫付款二维码）
export const  reqPayStatus =(orderId) =>{
       return ajax({
          url:`/payment/weixin/queryPayStatus/${orderId}`,
          method:'get'
       })
}

//22.获取我的订单列表('请求“我的订单”里面的数据')
export const reqMyOrderInfo = (page,limit)=>{
       return ajax({
              url:`/order/auth/${page}/${limit}`,
              method:'get'
       })
}
